package com.hwpt.hwaccount.feature.auth.utils;

public class AuthValidator {
    
    private static final int PHONE_LENGTH = 11;
    private static final int VERIFY_CODE_LENGTH = 6;
    private static final int MIN_PASSWORD_LENGTH = 6;
    
    public static boolean validatePhone(String phone) {
        return phone != null && phone.length() == PHONE_LENGTH;
    }
    
    public static boolean validateAccount(String account) {
        return account != null && !account.trim().isEmpty();
    }
    
    public static boolean validatePassword(String password) {
        return password != null && password.length() >= MIN_PASSWORD_LENGTH;
    }
    
    public static boolean validateVerifyCode(String verifyCode) {
        return verifyCode != null && verifyCode.length() == VERIFY_CODE_LENGTH;
    }
    
    public static boolean validateRegisterFirstStep(String phone, String verifyCode) {
        return validatePhone(phone) && validateVerifyCode(verifyCode);
    }
    
    public static boolean validateRegister(String password, String confirmPassword) {
        return validatePassword(password) && password.equals(confirmPassword);
    }
    
    public static String getPhoneError(String phone) {
        if (phone == null || phone.isEmpty()) {
            return "手机号不能为空";
        }
        if (phone.length() != PHONE_LENGTH) {
            return "手机号必须是11位数字";
        }
        return null;
    }
    
    public static String getAccountError(String account) {
        if (account == null || account.trim().isEmpty()) {
            return "账号不能为空";
        }
        return null;
    }
    
    public static String getPasswordError(String password) {
        if (password == null || password.isEmpty()) {
            return "密码不能为空";
        }
        if (password.length() < MIN_PASSWORD_LENGTH) {
            return "密码长度不能少于" + MIN_PASSWORD_LENGTH + "位";
        }
        return null;
    }
    
    public static String getVerifyCodeError(String verifyCode) {
        if (verifyCode == null || verifyCode.isEmpty()) {
            return "验证码不能为空";
        }
        if (verifyCode.length() != VERIFY_CODE_LENGTH) {
            return "验证码必须是" + VERIFY_CODE_LENGTH + "位数字";
        }
        return null;
    }
}